﻿using System;
using System.IO;
using System.Linq;

namespace MsTestUtilities.SolutionAnalysis.Testing
{
    public class SolutionAsserter
    {
        private SolutionFile _solutionFile;
               
        public SolutionAsserter(SolutionFile solutionFile)
        {
            _solutionFile = solutionFile;
        }

        public ProjectAssert ForAllProjects()
        {
            return new ProjectAssert(_solutionFile.Projects);
        }

        public ProjectAssert ForAllProjects(Predicate<CsProject> predicate)
        {
            return new ProjectAssert(_solutionFile.Projects.Where(p => predicate(p)));
        }

        private ProjectAssert ForProjectsWithTestType(TestType testType)
        {
            return ForAllProjects(p => p.TestType == testType);            
        }

        public ProjectAssert ForTestProjects()
        {
            return ForProjectsWithTestType(TestType.UnitTest);
        }

        public ProjectAssert ForNonTestProjects()
        {
            return ForProjectsWithTestType(TestType.NotTest);
        }        
    }
}
